
package pl.genapp.stocksense.libraries;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;

public final class JSONStringMaker {
	
	private static JSONObject prepareObject(Context context, String service, String method) {
		
		JSONObject res = new JSONObject();
		
		/**
		 * Dodawaie podstawowych dnaych do obiektu
		 */
		try {
			res.put("method", method);
			res.put("service", service);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		
		return res;
		
	}
	
	public static String getSentiments(Context context, int numberOfDays, String entityId) {
		
		JSONObject obj = prepareObject(context, "SentimentService", "getSentiments");
		
		try {
			obj.put("numberOfDays", numberOfDays);
			obj.put("entityId", entityId);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		
		return obj.toString();
		
	}
	
	public static String getNews(Context context, int numberOfNews, int offset) {
		
		JSONObject obj = prepareObject(context, "NewsService", "getNews");
		
		try {
			obj.put("numberOfNews", numberOfNews);
			obj.put("offset", offset);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		
		return obj.toString();
		
	}
	
	public static String getTopThreeNewsForEachSentiment(Context context) {
		
		JSONObject obj = prepareObject(context, "NewsService", "getTopThreeNewsForEachSentiment");
		
		return obj.toString();
		
	}
	
	
	
}
